<!--页面主要内容-->
<main class="lyear-layout-content">
    <div class="container-fluid p-t-15">
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body">
                        <form method="post" enctype="multipart/form-data" class="needs-validation" novalidate>
                            <!-- 项目名称 -->
                            <div class="form-group col-md-12">
                                <label for="name">项目名称</label>
                                <input type="text" class="form-control" id="name" name="name" value="{$Project['name']}" required
                                    placeholder="请输入项目名称" />
                                <div class="invalid-feedback">
                                    请输入项目名称
                                </div>
                            </div>
                            <div class="form-group col-md-12">
                                <button type="submit" class="btn btn-primary" target-form="add-form">确
                                    定</button>
                                <button type="button" class="btn btn-default"
                                    onclick="javascript:history.back(-1);return false;">返 回</button>
                            </div>
                        </form>
                        <script>
                            // Example starter JavaScript for disabling form submissions if there are invalid fields
                            (function () {
                                'use strict';
                                window.addEventListener('load', function () {
                                    // Fetch all the forms we want to apply custom Bootstrap validation styles to
                                    var forms = document.getElementsByClassName('needs-validation');
                                    // Loop over them and prevent submission
                                    var validation = Array.prototype.filter.call(forms, function (form) {
                                        form.addEventListener('submit', function (event) {
                                            if (form.checkValidity() === false) {
                                                event.preventDefault();
                                                event.stopPropagation();
                                            }
                                            form.classList.add('was-validated');
                                        }, false);
                                    });
                                }, false);
                            })();
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<!--End 页面主要内容-->

<script>
    $(function () {
        $('#name').change(function () {
            var name = $(this).val();
            $.ajax({
                // 提交方式
                type: 'POST',
                // 请求地址
                url: `{:url('admin/project/select')}`,
                data: {
                    name
                },
                // 请求返回的数据类型 text html json
                dataType: 'json',
                success: (result) => {
                    if (result.code === 0) {
                        $.notify({
                            message: result.msg,
                        }, {
                            delay: 1000,
                            type: 'warning'
                        })
                    }
                }
            })
        })
    })
</script>